package com.xwdeshj.controller;

import com.alibaba.fastjson.JSONObject;
import com.xwdeshj.service.XwSceincThemetypeService;
import com.xwdeshj.utils.IMoocExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by BKWJA on 2018/12/21.
 * 景区主题游类型控制层
 */
@Slf4j
@RequestMapping("SceThemeType")
@CrossOrigin(allowCredentials = "true")
@Controller
public class XwSceincThemetypeController extends IMoocExceptionHandler {

    @Autowired
    private XwSceincThemetypeService xwSceincThemetypeService;

    //获取全部的主题游信息列表,不分页，按添加日期排序
    @RequestMapping("/getAllSceThemetype")
    @ResponseBody
    public JSONObject getAllSceThemetype(){
        return  xwSceincThemetypeService.getAllSceThemetype();
    }

    /**
     * 景区主题游类型列表查询
     * @param pageindex 当前页码
     * @param pagesize 每页显示多少
     * @param starttime 开始时间
     * @param endtime 结束时间
     * @param sortfild 排序字段
     * @param sortway 排序方式
     * @return
     */
    @RequestMapping("/getSceThemetypelist")
    @ResponseBody
    public JSONObject getSceThemetypelist(@RequestParam(value = "pageindex",defaultValue = "1")Integer pageindex,
                                         @RequestParam(value = "pagesize",defaultValue = "10") Integer pagesize,
                                         @RequestParam(value = "starttime",defaultValue = "") String starttime,
                                         @RequestParam(value = "endtime",defaultValue = "") String endtime,
                                         @RequestParam(value = "sortfild",defaultValue = "scenic_theme_createtime") String sortfild,
                                         @RequestParam(value = "sortway",defaultValue = "desc")String sortway){
        return xwSceincThemetypeService.getSceThemetypelist(pageindex,pagesize,starttime,endtime,sortfild,sortway);
    }

    /**
     * 修改，新增景区游玩类型信息
     * @param scenic_theme_encryptId  景区主题游类型加密id
     * @param scenic_themee_desc 景区主题游类型文字
     * @return
     */
    @RequestMapping("/updateSceThemetype")
    @ResponseBody
    public JSONObject updateSceThemetype(String scenic_theme_encryptId,String scenic_themee_desc){
        return xwSceincThemetypeService.updateSceThemetype(scenic_theme_encryptId,scenic_themee_desc);
    }

    /**
     * 根据scenic_theme_encryptId景区主题游类型加密id，删除对应的记录
     * @param scenic_theme_encryptId
     * @return
     */
    @RequestMapping("/delSceThemetype")
    @ResponseBody
    public JSONObject delSceThemetype(String scenic_theme_encryptId){
        return xwSceincThemetypeService.delSceThemetype(scenic_theme_encryptId);
    }

}
